import path from 'node:path'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
import { env } from '../../env'

export default defineConfig({
  server: {
    // we specify the port here for repl to load v1-components(esm-pkg) from http://localhost:5173/v1-components.js
    port: env.V1_FE_PORT,
  },
  plugins: [react(), TanStackRouterVite()],
  envDir: '../../',
  envPrefix: 'V1',
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      'react': 'openinula',
      'react-dom': 'openinula',
      'react/jsx-dev-runtime': 'openinula/jsx-dev-runtime',
      'react/jsx-runtime': 'openinula/jsx-runtime',
    },
  },
})
